package com.liu.test0303.sys.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Queue;

@RestController
public class UserController {


    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    @Autowired
    private Queue queue2;

    private  int id=0;

    @PostMapping("register")
    public  String register(){
        int ids=++id;
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(ids+"注册成功");
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(ids+"发送邮件成功");

        return null;
    }

    @PostMapping("register2")
    public  String register2(){
        int ids=++id;
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        jmsMessagingTemplate.convertAndSend(queue2, ids);
        System.out.println(ids+"注册成功");


        return null;
    }


}
